{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 作者：chenyujing（微信号:15280006510  QQ: 594462206）,欢迎交流\n",
    "################ \n",
    "##  使用者一定要准备的工作：\n",
    "##### 1.打开三个谷歌浏览器程序，第一个为我们跑的脚本 ，第二个为抖音的浏览器，第三个也是抖音的浏览器。\n",
    "#     且我们的脚本以窗口形式展式；抖音器打开抖音的首页，然后浏览器最大化。\n",
    "#     首页eg:https://www.douyin.com/user/MS4wLjABAAAAHFPZZ00dYU58-Ql2Ls9ExPSr1PgX7rH-OIo8TJ6lP9_Vd8KYBcaC2jL4mXt-d6Qe\n",
    "##### 2.确保谷歌浏览器在任务栏中的第一个位置；确保微信（打开要发送给的聊天目的窗口）在任务栏中的第二个位置。\n",
    "##### 3.配置“作品数量按钮的位置”、 “刷新按钮的位置”、“浏览器组配置”\n",
    "##### 4. 配置完时间后，运行此脚本：Cell -> Run All \n",
    "#        运行后，把浏览器最小化就好（切记，不要关闭这个浏览器页面”；\n",
    "#        也不要关闭“管理员：Anaconda Prompt”这个命令窗口）\n",
    "#     5. 注意：如果脚本一旦运行起来，想修改配置数据，需要先将程序停止，然后再启动脚本 \n",
    "#        停止脚本的方法：Kernel -> Restart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#################### 要配置的参数   ################################3\n",
    "# \n",
    "# 作品数量按钮的位置 \n",
    "ZUO_PIN_SHU_X = 224#LEI_DIAN_FW_LEFT + LEI_DIAN_FW_WIDTH/2 -160\n",
    "ZUO_PIN_SHU_Y = 410#LEI_DIAN_FW_TOP + 200\n",
    "ZUO_PIN_SHU_WIDTH = 100\n",
    "ZUO_PIN_SHU_HEIGHT = 35\n",
    "# 刷新按钮的位置 \n",
    "SHUA_XIN_X = 0 + 95\n",
    "SHUA_XIN_Y = 0 + 55\n",
    "#\n",
    "#\n",
    "# 浏览器组配置\n",
    "HOME_PAGE_GROUP_LIST = []\n",
    "# 第一个浏览器里打开的抖音首页的个数为2\n",
    "HOME_PAGE_GROUP_LIST.append({\"video_home_page_count\":2, \"zuo_pin_shu_save_path\":\"zuo_pin_shu_from_dou_yin_1.txt\", \"icon_pos\":(0, 0), \"device_list\":[]})\n",
    "# 第二个浏览器里打开的抖音首页的个数为3\n",
    "HOME_PAGE_GROUP_LIST.append({\"video_home_page_count\":3, \"zuo_pin_shu_save_path\":\"zuo_pin_shu_from_dou_yin_2.txt\", \"icon_pos\":(0, 0), \"device_list\":[]})\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pyautogui\n",
    "import time \n",
    "import shutil \n",
    "import os\n",
    "import pyperclip\n",
    "import win32gui\n",
    "from hashlib import md5\n",
    "import stat\n",
    "from PIL import Image\n",
    "import time\n",
    "from random import sample\n",
    "import test_baidu_ocr  \n",
    "import random\n",
    "import win32clipboard as w\n",
    "import win32con\n",
    "\n",
    "\n",
    "\n",
    "#\"\"\"\n",
    "LEI_DIAN_TITLE_BEGIN_LIST = [\"抖音 - Google Chrome\"]\n",
    "#\"\"\"\n",
    "SCREENSHOT_SAVE_DIR = \"./screenshot_img\"\n",
    "if False == os.path.exists(SCREENSHOT_SAVE_DIR):\n",
    "    os.mkdir(SCREENSHOT_SAVE_DIR)\n",
    "\n",
    "LEI_DIAN_FW = None\n",
    "LEI_DIAN_FW_LEFT = 0\n",
    "LEI_DIAN_FW_RIGHT = 0\n",
    "LEI_DIAN_FW_TOP = 0\n",
    "LEI_DIAN_FW_BOTTOM = 0\n",
    "LEI_DIAN_FW_WIDTH = 0\n",
    "LEI_DIAN_FW_HEIGHT = 0\n",
    "\n",
    "\n",
    "g_img_count = 0\n",
    "\n",
    "if True == os.path.exists(SCREENSHOT_SAVE_DIR):\n",
    "    # chenyj test\n",
    "    os.chmod(SCREENSHOT_SAVE_DIR, stat.S_IWUSR)\n",
    "    # chenyj test\n",
    "    #shutil.rmtree(SCREENSHOT_SAVE_DIR)\n",
    "    pass\n",
    "# chenyj test\n",
    "#os.mkdir(SCREENSHOT_SAVE_DIR)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 从文件中加载原有作品数\n",
    "def load_zuo_pin_shu_from_file(zuo_pin_shu_save_path):\n",
    "    zuo_pin_shu_of_homepage_list = []\n",
    "    if not os.path.exists(zuo_pin_shu_save_path):\n",
    "        return zuo_pin_shu_of_homepage_list\n",
    "    file_read = open(zuo_pin_shu_save_path, \"r\", encoding='UTF-8')\n",
    "    lines = file_read.readlines()\n",
    "    for line in lines:\n",
    "        line = line.strip()\n",
    "        if len(line) < 4:\n",
    "            continue\n",
    "        data_list = line.split(\"\\t\")\n",
    "        assert len(data_list) == 2, \"{}内数据格式不合法\".format(zuo_pin_shu_save_path)\n",
    "        zuo_pin_shu_of_homepage_list.append({\"name\":data_list[0], \"zuo_pin_shu\":int(data_list[1])})\n",
    "    file_read.close()\n",
    "    print(\"从文件{}中，共读取到{}个主页的作品量数据\".format(zuo_pin_shu_save_path, len(zuo_pin_shu_of_homepage_list)))\n",
    "    return zuo_pin_shu_of_homepage_list\n",
    "\n",
    "# 将作品数保存到文件中\n",
    "def save_zuo_pin_shu_to_file(device_list, zuo_pin_shu_save_path):\n",
    "    file_write = open(zuo_pin_shu_save_path, \"w\", encoding='UTF-8')\n",
    "    for device in device_list:\n",
    "        file_write.write(\"{}\\t{}\\n\".format(device[\"name\"], device[\"zuo_pin_shu\"]))\n",
    "    file_write.close()\n",
    "    print(\"将作品数保存到文件{}中\".format(zuo_pin_shu_save_path))\n",
    "    return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def init():\n",
    "    global LEI_DIAN_FW_LEFT\n",
    "    global LEI_DIAN_FW_RIGHT\n",
    "    global LEI_DIAN_FW_TOP\n",
    "    global LEI_DIAN_FW_BOTTOM\n",
    "    global LEI_DIAN_FW_WIDTH\n",
    "    global LEI_DIAN_FW_HEIGHT\n",
    "    global  LEI_DIAN_FW\n",
    "    fw_all = pyautogui.getAllWindows() # 返回屏幕上每个可见窗口的窗口对象列表。\n",
    "    b_found = False\n",
    "    for fw in fw_all:\n",
    "        for LEI_DIAN_TITLE_BEGIN in LEI_DIAN_TITLE_BEGIN_LIST:\n",
    "            if LEI_DIAN_TITLE_BEGIN in fw.title:\n",
    "                # 要求此页面是可见的\n",
    "                if fw.left < -500:\n",
    "                    continue\n",
    "                                     \n",
    "                print(fw)\n",
    "                LEI_DIAN_FW_LEFT = fw.left\n",
    "                LEI_DIAN_FW_RIGHT = fw.right\n",
    "                LEI_DIAN_FW_TOP = fw.top\n",
    "                LEI_DIAN_FW_BOTTOM = fw.bottom\n",
    "                LEI_DIAN_FW_WIDTH = fw.right - fw.left\n",
    "                LEI_DIAN_FW_HEIGHT = fw.bottom - fw.top\n",
    "                LEI_DIAN_FW = fw\n",
    "                print(\"LEI_DIAN_FW_LEFT:{}\".format(LEI_DIAN_FW_LEFT))\n",
    "                print(\"LEI_DIAN_FW_TOP:{}\".format(LEI_DIAN_FW_TOP))\n",
    "                print(\"LEI_DIAN_FW_BOTTOM:{}\".format(LEI_DIAN_FW_BOTTOM))\n",
    "                print(\"LEI_DIAN_FW_WIDTH:{}\".format(LEI_DIAN_FW_WIDTH))\n",
    "                print(\"LEI_DIAN_FW_HEIGHT:{}\".format(LEI_DIAN_FW_HEIGHT))\n",
    "                b_found = True\n",
    "                break \n",
    "                \n",
    "    assert b_found == True, \"没有找到模拟器窗口\"\n",
    "    \n",
    "    return\n",
    "    \n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_device_list():\n",
    "    device_list = []\n",
    "    \n",
    "    # 找到所有设备的table的名字及位置\n",
    "    img_after_cut_path = SCREENSHOT_SAVE_DIR + \"/\" + \"top_banner\" + \".png\"\n",
    "    pyautogui.screenshot(img_after_cut_path, region=(LEI_DIAN_FW_LEFT, LEI_DIAN_FW_TOP, LEI_DIAN_FW_WIDTH, LEI_DIAN_FW_TOP_BANNER))\n",
    "    print('Top banner保存到:{}'.format(img_after_cut_path))\n",
    "    ocr_result = test_baidu_ocr.get_ocr_result(img_after_cut_path)\n",
    "    print(\"OCR的结果：\", ocr_result)\n",
    "    for word_result in ocr_result[\"words_result\"]:\n",
    "        words = word_result[\"words\"]\n",
    "        location = word_result[\"location\"]\n",
    "        if words == \"×+\" or words == \"X\" or words == \"×十\" or words == \"x+\":\n",
    "            continue\n",
    "        # 跳过右上角的控制按钮 \n",
    "        if location['left'] > 1026:\n",
    "            continue\n",
    "        words_list = [words]\n",
    "        location_list = [location]\n",
    "        #          '×Il Xiaomi MI2sC-3×l Xiaomi MI2sC-2×+'\n",
    "        #          'Il Xiaomi MI2sC-2×il Meitu MP1709×,l Xiaomi M2sC-4×Il Xiaomi MI2s'\n",
    "        # 将以上特例按×切开做特殊处理\n",
    "        words_ = words.replace(\"x\", \"×\")\n",
    "        words_ = words_.replace(\"X\", \"×\")\n",
    "        words_ = words_.strip(\"×\")\n",
    "        str_list = words_.split(\"×\")\n",
    "        str_list = [str for str in str_list if len(str) >= 2]\n",
    "        if len(str_list) >= 1:   \n",
    "            print(\"！！！远程设备tab特殊处理, str_list:{}\".format(str_list))\n",
    "            words_list = []\n",
    "            location_list = []\n",
    "            for i, str in enumerate(str_list):\n",
    "                words1 = str\n",
    "                words_list.append(words1)\n",
    "                location1 = {\"left\":location[\"left\"] + int(location[\"width\"]/len(str_list))*i, \"top\":location[\"top\"], \"width\":int(location[\"width\"]/len(str_list)), \"height\":location[\"height\"]}\n",
    "                location_list.append(location1)\n",
    "                \n",
    "        for i, words in enumerate(words_list):\n",
    "            location = location_list[i]\n",
    "            x = LEI_DIAN_FW_LEFT + int(location[\"left\"] + location[\"width\"]/3)\n",
    "            y = LEI_DIAN_FW_TOP + int(location[\"top\"] + location[\"height\"]/3)\n",
    "            device_list.append({\"name\":words, \"click_loccation\":(x, y)})\n",
    "    # 确保找到远程设备\n",
    "    assert len(device_list) != 0, \"没有找到远程控制的设备\" \n",
    "    print('找到的远程设备有【{}】个:{}'.format(len(device_list), device_list))\n",
    "    \n",
    "    return device_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "LEI_DIAN_FW_TOP_BANNER = 33\n",
    "LEI_DIAN_FW_RIGHT_BANNER = 40\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Win32Window left=\"-8\", top=\"-8\", width=\"1382\", height=\"744\", title=\"童心手工屋的主页 - 抖音 - Google Chrome\">\n",
      "LEI_DIAN_FW_LEFT:-8\n",
      "LEI_DIAN_FW_TOP:-8\n",
      "LEI_DIAN_FW_BOTTOM:736\n",
      "LEI_DIAN_FW_WIDTH:1382\n",
      "LEI_DIAN_FW_HEIGHT:744\n",
      "<Win32Window left=\"-8\", top=\"-8\", width=\"1382\", height=\"744\", title=\"生活妙招库的主页 - 抖音 - Google Chrome\">\n",
      "LEI_DIAN_FW_LEFT:-8\n",
      "LEI_DIAN_FW_TOP:-8\n",
      "LEI_DIAN_FW_BOTTOM:736\n",
      "LEI_DIAN_FW_WIDTH:1382\n",
      "LEI_DIAN_FW_HEIGHT:744\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'\\nfor device_info in DEVICE_LIST:\\n    device_click_location = device_info[\"click_loccation\"]\\n    pyautogui.moveTo(device_click_location[0], device_click_location[1],duration=0.5)\\n    pyautogui.click()\\n    time.sleep(2)\\n'"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 抖音测试\n",
    "\n",
    "# 初始化\n",
    "init()\n",
    "\n",
    "############配置数据区############################\n",
    "\n",
    "# 第一行点赞行\n",
    "DIAN_ZAN_SHU_HANG_1_X =   LEI_DIAN_FW_LEFT + LEI_DIAN_FW_WIDTH/2 - 160\n",
    "DIAN_ZAN_SHU_HANG_1_Y = LEI_DIAN_FW_TOP + 520\n",
    "DIAN_ZAN_SHU_HANG_1_WIDTH = 700\n",
    "DIAN_ZAN_SHU_HANG_1_HEIGHT = 40\n",
    "# 分享按钮 \n",
    "FEN_XIANG_X = LEI_DIAN_FW_LEFT + LEI_DIAN_FW_WIDTH/2 + 640\n",
    "FEN_XIANG_Y = LEI_DIAN_FW_TOP + 620\n",
    "# 链接按钮 \n",
    "LIAN_JIE_X = LEI_DIAN_FW_LEFT + LEI_DIAN_FW_WIDTH/2 + 595\n",
    "LIAN_JIE_Y = LEI_DIAN_FW_TOP + 620\n",
    "# 关闭视频页面按钮\n",
    "CLOSE_VIDEO_X = LEI_DIAN_FW_LEFT + 85\n",
    "CLOSE_VIDEO_Y = LEI_DIAN_FW_TOP + 180\n",
    "# 任务栏中的微信聊天图标\n",
    "#   要求打开“文件传输助手”，且放在任务栏图标从左往右的第二个\n",
    "WEI_XIN_ICON_X = LEI_DIAN_FW_LEFT + 519\n",
    "WEI_XIN_ICON_Y = LEI_DIAN_FW_BOTTOM + 10\n",
    "# 任务栏中的谷歌浏览器图标\n",
    "#    放在任务栏图标从左往右的第一个\n",
    "GU_GE_ICON_X = LEI_DIAN_FW_LEFT + 465\n",
    "GU_GE_ICON_Y = LEI_DIAN_FW_BOTTOM + 10\n",
    "GU_GE_DOU_YIN_1_ICON_X = LEI_DIAN_FW_LEFT + 465\n",
    "GU_GE_DOU_YIN_1_ICON_Y =LEI_DIAN_FW_BOTTOM - 100\n",
    "GU_GE_DOU_YIN_2_ICON_X = LEI_DIAN_FW_LEFT + 650\n",
    "GU_GE_DOU_YIN_2_ICON_Y =LEI_DIAN_FW_BOTTOM - 100\n",
    "HOME_PAGE_GROUP_LIST[0][\"icon_pos\"] = (GU_GE_DOU_YIN_1_ICON_X, GU_GE_DOU_YIN_1_ICON_Y)\n",
    "HOME_PAGE_GROUP_LIST[1][\"icon_pos\"] = (GU_GE_DOU_YIN_2_ICON_X, GU_GE_DOU_YIN_2_ICON_Y)\n",
    "###############################################################################\n",
    "# 测试刷新按钮 \n",
    "#pyautogui.moveTo(SHUA_XIN_X, SHUA_XIN_Y,duration=0.5)\n",
    "#pyautogui.click()\n",
    "#time.sleep(4)\n",
    "\n",
    "# 测试第一行点赞数\n",
    "\"\"\"\n",
    "pyautogui.moveTo(DIAN_ZAN_SHU_HANG_1_X, DIAN_ZAN_SHU_HANG_1_Y,duration=0.5)\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(DIAN_ZAN_SHU_HANG_1_X + DIAN_ZAN_SHU_HANG_1_WIDTH, DIAN_ZAN_SHU_HANG_1_Y + DIAN_ZAN_SHU_HANG_1_HEIGHT,duration=0.5)\n",
    "#     点赞数OCR\n",
    "img_after_cut_path = SCREENSHOT_SAVE_DIR + \"/\" + \"zuo_pin_shu\" + \".png\"\n",
    "pyautogui.screenshot(img_after_cut_path, region=(DIAN_ZAN_SHU_HANG_1_X, DIAN_ZAN_SHU_HANG_1_Y, DIAN_ZAN_SHU_HANG_1_WIDTH, DIAN_ZAN_SHU_HANG_1_HEIGHT))\n",
    "ocr_result = test_baidu_ocr.get_ocr_result(img_after_cut_path)\n",
    "print(\"OCR的结果：\", ocr_result)\n",
    "for word_result in ocr_result[\"words_result\"]:\n",
    "    words = word_result[\"words\"]\n",
    "#{'location': {'height': 15, 'left': 16, 'top': 23, 'width': 64}, 'words': '28.6w'}, \n",
    "#{'location': {'height': 15, 'left': 266, 'top': 23, 'width': 64}, 'words': '72.8w'}, \n",
    "\"\"\"\n",
    "\n",
    "# 测试获取链接\n",
    "\"\"\"\n",
    "pyautogui.moveTo(FEN_XIANG_X, FEN_XIANG_Y,duration=0.5)\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(LIAN_JIE_X, LIAN_JIE_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "\"\"\"\n",
    "\n",
    "# 测试关闭视频按钮\n",
    "#pyautogui.moveTo(CLOSE_VIDEO_X, CLOSE_VIDEO_Y,duration=0.5)\n",
    "\n",
    "# 测试任务栏中的谷歌浏览器图标（一定要的测试项）\n",
    "pyautogui.moveTo(GU_GE_ICON_X, GU_GE_ICON_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(GU_GE_DOU_YIN_1_ICON_X, GU_GE_DOU_YIN_1_ICON_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(GU_GE_ICON_X, GU_GE_ICON_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(GU_GE_DOU_YIN_2_ICON_X, GU_GE_DOU_YIN_2_ICON_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "\n",
    "# 测试任务栏中的微信聊天图标（一定要的测试项）\n",
    "#\"\"\"\n",
    "pyautogui.moveTo(WEI_XIN_ICON_X, WEI_XIN_ICON_Y,duration=0.5)\n",
    "pyautogui.click()\n",
    "time.sleep(1)\n",
    "pyperclip.copy(\"监控新作品脚本成功启动\")\n",
    "time.sleep(1)\n",
    "pyautogui.hotkey('Ctrl', 'v')\n",
    "time.sleep(0.5)\n",
    "pyautogui.press('enter') \n",
    "time.sleep(2)\n",
    "#\"\"\"\n",
    "\n",
    "# 测试作品数\n",
    "\"\"\"\n",
    "pyautogui.moveTo(ZUO_PIN_SHU_X, ZUO_PIN_SHU_Y,duration=0.5)\n",
    "time.sleep(1)\n",
    "pyautogui.moveTo(ZUO_PIN_SHU_X + ZUO_PIN_SHU_WIDTH, ZUO_PIN_SHU_Y + ZUO_PIN_SHU_HEIGHT,duration=0.5)\n",
    "#     作品数OCR\n",
    "img_after_cut_path = SCREENSHOT_SAVE_DIR + \"/\" + \"zuo_pin_shu\" + \".png\"\n",
    "pyautogui.screenshot(img_after_cut_path, region=(ZUO_PIN_SHU_X, ZUO_PIN_SHU_Y, ZUO_PIN_SHU_WIDTH, ZUO_PIN_SHU_HEIGHT))\n",
    "ocr_result = test_baidu_ocr.get_ocr_result(img_after_cut_path)\n",
    "print(\"OCR的结果：\", ocr_result)\n",
    "for word_result in ocr_result[\"words_result\"]:\n",
    "    words = word_result[\"words\"]\n",
    "    assert \"作品\" in words\n",
    "\"\"\"\n",
    "\n",
    "# 远程设备table切换测试\n",
    "\"\"\"\n",
    "for device_info in DEVICE_LIST:\n",
    "    device_click_location = device_info[\"click_loccation\"]\n",
    "    pyautogui.moveTo(device_click_location[0], device_click_location[1],duration=0.5)\n",
    "    pyautogui.click()\n",
    "    time.sleep(2)\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Top banner保存到:./screenshot_img/top_banner.png\n",
      "OCR的结果： {'log_id': 1602275916642704955, 'words_result': [{'words': '小美据秘的主页-抖音', 'location': {'top': 15, 'left': 25, 'width': 146, 'height': 15}}, {'words': '×小生活妙招库的主页-抖音', 'location': {'top': 14, 'left': 232, 'width': 191, 'height': 17}}, {'words': '×十', 'location': {'top': 16, 'left': 470, 'width': 53, 'height': 13}}, {'words': '▣', 'location': {'top': 16, 'left': 1297, 'width': 17, 'height': 10}}, {'words': '×', 'location': {'top': 14, 'left': 1311, 'width': 48, 'height': 14}}], 'words_result_num': 5}\n",
      "！！！远程设备tab特殊处理, str_list:['小美据秘的主页-抖音']\n",
      "！！！远程设备tab特殊处理, str_list:['小生活妙招库的主页-抖音']\n",
      "找到的远程设备有【2】个:[{'name': '小美据秘的主页-抖音', 'click_loccation': (65, 12)}, {'name': '小生活妙招库的主页-抖音', 'click_loccation': (287, 11)}]\n",
      "从文件zuo_pin_shu_from_dou_yin_1.txt中，共读取到2个主页的作品量数据\n",
      "文件zuo_pin_shu_from_dou_yin_1.txt中读取的主页数与现在的主页数一致，将原有作品数还原\n",
      "Top banner保存到:./screenshot_img/top_banner.png\n",
      "OCR的结果： {'log_id': 1602275933894209535, 'words_result': [{'words': '绘画课堂的主页-抖音', 'location': {'top': 15, 'left': 25, 'width': 146, 'height': 15}}, {'words': '×可乐麻麻的主页-抖音', 'location': {'top': 15, 'left': 232, 'width': 178, 'height': 15}}, {'words': '×童心手工屋的主页-抖音', 'location': {'top': 16, 'left': 472, 'width': 190, 'height': 15}}, {'words': 'x+', 'location': {'top': 16, 'left': 706, 'width': 56, 'height': 13}}, {'words': '▣', 'location': {'top': 16, 'left': 1297, 'width': 17, 'height': 10}}, {'words': 'X', 'location': {'top': 14, 'left': 1311, 'width': 48, 'height': 14}}], 'words_result_num': 6}\n",
      "！！！远程设备tab特殊处理, str_list:['绘画课堂的主页-抖音']\n",
      "！！！远程设备tab特殊处理, str_list:['可乐麻麻的主页-抖音']\n",
      "！！！远程设备tab特殊处理, str_list:['童心手工屋的主页-抖音']\n",
      "找到的远程设备有【3】个:[{'name': '绘画课堂的主页-抖音', 'click_loccation': (65, 12)}, {'name': '可乐麻麻的主页-抖音', 'click_loccation': (283, 12)}, {'name': '童心手工屋的主页-抖音', 'click_loccation': (527, 13)}]\n",
      "从文件zuo_pin_shu_from_dou_yin_2.txt中，共读取到3个主页的作品量数据\n",
      "文件zuo_pin_shu_from_dou_yin_2.txt中读取的主页数与现在的主页数一致，将原有作品数还原\n"
     ]
    }
   ],
   "source": [
    "\n",
    "for home_page_group in HOME_PAGE_GROUP_LIST: \n",
    "    #  切到各个浏览器组\n",
    "    pyautogui.moveTo(GU_GE_ICON_X, GU_GE_ICON_Y,duration=0.5)\n",
    "    pyautogui.click()\n",
    "    time.sleep(1)\n",
    "    pyautogui.moveTo(home_page_group[\"icon_pos\"][0], home_page_group[\"icon_pos\"][1],duration=0.5)\n",
    "    pyautogui.click()\n",
    "    time.sleep(1)\n",
    "    # 获得主页列表\n",
    "    home_page_group[\"device_list\"] = get_device_list()\n",
    "\n",
    "    assert home_page_group[\"video_home_page_count\"] == len(home_page_group[\"device_list\"]), \"本应该有{}个主页，却只找到{}个\".format(home_page_group[\"video_home_page_count\"],  len(home_page_group[\"device_list\"]))\n",
    "\n",
    "    zuo_pin_shu_of_homepage_list = load_zuo_pin_shu_from_file(home_page_group[\"zuo_pin_shu_save_path\"])\n",
    "    if len(zuo_pin_shu_of_homepage_list) != 0:\n",
    "        if len(zuo_pin_shu_of_homepage_list) == len(home_page_group[\"device_list\"]):\n",
    "            print(\"文件{}中读取的主页数与现在的主页数一致，将原有作品数还原\".format(home_page_group[\"zuo_pin_shu_save_path\"]))\n",
    "            for i, zuo_pin_shu_of_homepage in enumerate(zuo_pin_shu_of_homepage_list):\n",
    "                home_page_group[\"device_list\"][i][\"zuo_pin_shu\"] = zuo_pin_shu_of_homepage[\"zuo_pin_shu\"]\n",
    "        else:\n",
    "            print(\"文件{}中读取的主页数与现在的主页数不一致，原有数据丢弃\".format(home_page_group[\"zuo_pin_shu_save_path\"]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "########## GUI 控制功能\n",
    "# 控制鼠标键盘使用的模块为：pyautogui，这个模块操作起鼠标键盘的时候，非常的迅速，\n",
    "# 而且如果该模块控制了鼠标后，程序比较难关闭，这时我们有两个方法专门针对以上的情况\n",
    "# 自动 防故障功能\n",
    "#      默认这项功能为True, 这项功能意味着：当鼠标的指针在屏幕的最坐上方，程序会报错；目的是为了防止程序无法停止；\n",
    "pyautogui.FAILSAFE = True  \n",
    "\n",
    "# 停顿功能\n",
    "#     意味着所有pyautogui的指令都要暂停一秒；其他指令不会停顿；这样做，可以防止键盘鼠标操作太快；\n",
    "pyautogui.PAUSE = 0.2\n",
    "# 调用每个PyAutoGUI函数后，会有十分之一秒的延迟，使用户有时间将鼠标猛撞到角落以触发故障保险。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 微信通知 \n",
    "def wei_xin_notify(str_in):\n",
    "    str_in = \"【jupyter自动化】\" + str_in\n",
    "    print(str_in)\n",
    "    pyautogui.moveTo(WEI_XIN_ICON_X, WEI_XIN_ICON_Y,duration=0.5)\n",
    "    pyautogui.click()\n",
    "    time.sleep(1)\n",
    "    pyperclip.copy(str_in)\n",
    "    time.sleep(1)\n",
    "    pyautogui.hotkey('Ctrl', 'v')\n",
    "    time.sleep(0.5)\n",
    "    pyautogui.press('enter') \n",
    "    time.sleep(6)\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取剪切板内容 \n",
    "import win32clipboard as w\n",
    "import win32con\n",
    "def get_text():\n",
    "    w.OpenClipboard()\n",
    "    d = w.GetClipboardData(win32con.CF_TEXT)\n",
    "    w.CloseClipboard()\n",
    "    return d.decode('GBK')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 获取当前页面点赞数最少的视频的链接 \n",
    "def get_video_url_of_dian_zan_least():\n",
    "    url_new_video = \"\"\n",
    "    least_dian_zan_dict = {}\n",
    " \n",
    "    MAX_LINE_COUNT = 2\n",
    "    now_line_index = 0\n",
    "    while now_line_index < MAX_LINE_COUNT:\n",
    "        now_line_index += 1\n",
    "        \n",
    "        if now_line_index != 1:\n",
    "            # 向下滚动一行\n",
    "            time.sleep(1)\n",
    "            pyautogui.scroll(-400,1000,700)\n",
    "            time.sleep(1)\n",
    "        # 获取此行所有视频中最少点赞数\n",
    "        pyautogui.moveTo(DIAN_ZAN_SHU_HANG_1_X, DIAN_ZAN_SHU_HANG_1_Y,duration=0.5)\n",
    "        time.sleep(1)\n",
    "        pyautogui.moveTo(DIAN_ZAN_SHU_HANG_1_X + DIAN_ZAN_SHU_HANG_1_WIDTH, DIAN_ZAN_SHU_HANG_1_Y + DIAN_ZAN_SHU_HANG_1_HEIGHT,duration=0.5)\n",
    "        #     点赞数OCR\n",
    "        img_after_cut_path = SCREENSHOT_SAVE_DIR + \"/\" + \"dian_zan\" + \".png\"\n",
    "        pyautogui.screenshot(img_after_cut_path, region=(DIAN_ZAN_SHU_HANG_1_X, DIAN_ZAN_SHU_HANG_1_Y, DIAN_ZAN_SHU_HANG_1_WIDTH, DIAN_ZAN_SHU_HANG_1_HEIGHT))\n",
    "        ocr_result = test_baidu_ocr.get_ocr_result(img_after_cut_path)\n",
    "        print(\"OCR的结果：\", ocr_result)\n",
    "        if \"words_result\" not in ocr_result:\n",
    "            print(\"!!!!!此次OCR结果为空\")\n",
    "            continue\n",
    "            \n",
    "        for word_result in ocr_result[\"words_result\"]:\n",
    "            words = word_result[\"words\"]\n",
    "            #'location': {'height': 14, 'left': 518, 'top': 24, 'width': 69}, 'words': '0115.1w'}] \n",
    "            if \"w\" in words or \"W\" in words or \"k\" in words or \"K\" in words:\n",
    "                continue\n",
    "            if words[0] == \"0\" or words[0] == \"Q\":\n",
    "                words = words[1:]\n",
    "            \n",
    "            try:\n",
    "                dian_zan_count = int(words)\n",
    "            except ValueError:\n",
    "                continue\n",
    "            if dian_zan_count > 100:\n",
    "                continue\n",
    "            if \"dian_zan_count\" not in least_dian_zan_dict:\n",
    "                least_dian_zan_dict[\"dian_zan_count\"] = dian_zan_count\n",
    "                least_dian_zan_dict[\"location\"] = word_result[\"location\"]\n",
    "            if  least_dian_zan_dict[\"dian_zan_count\"] > dian_zan_count:\n",
    "                least_dian_zan_dict[\"dian_zan_count\"] = dian_zan_count\n",
    "                least_dian_zan_dict[\"location\"] = word_result[\"location\"]\n",
    "        # 获取此行视频中点赞数最少的视频的链接 \n",
    "        if \"dian_zan_count\" in least_dian_zan_dict:\n",
    "            pyautogui.moveTo(DIAN_ZAN_SHU_HANG_1_X + least_dian_zan_dict[\"location\"][\"left\"], DIAN_ZAN_SHU_HANG_1_Y + least_dian_zan_dict[\"location\"][\"top\"],duration=0.5)\n",
    "            pyautogui.click()\n",
    "            time.sleep(3)\n",
    "            pyautogui.moveTo(FEN_XIANG_X, FEN_XIANG_Y,duration=0.5)\n",
    "            time.sleep(2)\n",
    "            pyautogui.moveTo(LIAN_JIE_X, LIAN_JIE_Y,duration=0.5)\n",
    "            pyautogui.click()\n",
    "            time.sleep(1)\n",
    "            url_new_video = get_text()\n",
    "            print(\"获得新视频的url是:{}\".format(url_new_video))\n",
    "            # 关闭此视频页面\n",
    "            pyautogui.moveTo(CLOSE_VIDEO_X, CLOSE_VIDEO_Y,duration=0.5)\n",
    "            pyautogui.click()\n",
    "            time.sleep(1)\n",
    "            \n",
    "            return url_new_video\n",
    "    \n",
    "    \n",
    "    return url_new_video"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#pyautogui.scroll(20)  \n",
    "#time.sleep(1)\n",
    "#pyautogui.scroll(-200,1000,700)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#  每完成一个循环，等待的时间数(秒)\n",
    "INTER_WAIT_SECONDS = 30\n",
    "\n",
    "# 新视频\n",
    "new_video_url_list = set()\n",
    "\n",
    "# 循环找出有视频更新的主页\n",
    "def loop_look_zuo_pin_shu():\n",
    "    \n",
    "    init()\n",
    "    g_i_test_count = 0\n",
    "    begin_time = time.time()\n",
    "    i_current_device_index = 0\n",
    "    i_current_group_index = 0\n",
    "    while g_i_test_count < 2000:\n",
    "        g_i_test_count += 1\n",
    "\n",
    "        if g_i_test_count % 2 == 0:\n",
    "            past_time = time.time() - begin_time\n",
    "            print(\"已经完成了{}个主页,平均速度{}个/秒，{}秒/个\".format(g_i_test_count, g_i_test_count/past_time, past_time/g_i_test_count))\n",
    "        \n",
    "        # 切换浏览器组\n",
    "        if i_current_device_index == 0:\n",
    "            home_page_group = HOME_PAGE_GROUP_LIST[i_current_group_index]\n",
    "            DEVICE_LIST = home_page_group[\"device_list\"]\n",
    "            pyautogui.moveTo(GU_GE_ICON_X, GU_GE_ICON_Y,duration=0.5)\n",
    "            pyautogui.click()\n",
    "            time.sleep(1)\n",
    "            pyautogui.moveTo(home_page_group[\"icon_pos\"][0], home_page_group[\"icon_pos\"][1],duration=0.5)\n",
    "            pyautogui.click()\n",
    "            time.sleep(1)\n",
    "            \n",
    "            i_current_group_index += 1\n",
    "            if i_current_group_index >= len(HOME_PAGE_GROUP_LIST):\n",
    "                i_current_group_index = 0\n",
    "    \n",
    "        \n",
    "        # 切换设备\n",
    "        click_location = DEVICE_LIST[i_current_device_index][\"click_loccation\"]\n",
    "        pyautogui.moveTo(click_location[0], click_location[1],duration=1)\n",
    "        pyautogui.click()\n",
    "        time.sleep(1)\n",
    "               \n",
    "        # 按下刷新按钮  \n",
    "        pyautogui.moveTo(SHUA_XIN_X, SHUA_XIN_Y,duration=0.5)\n",
    "        pyautogui.click()\n",
    "        time.sleep(8)\n",
    "        \n",
    "        # 先向上滚到顶 \n",
    "        pyautogui.moveTo(ZUO_PIN_SHU_X, ZUO_PIN_SHU_Y,duration=0.5)\n",
    "        pyautogui.click()\n",
    "        pyautogui.scroll(1000,1000,700)\n",
    "    \n",
    "        # 获取作品数  \n",
    "        TRY_OCR_COUNT = 5\n",
    "        while TRY_OCR_COUNT > 0:\n",
    "            TRY_OCR_COUNT -= 1\n",
    "            pyautogui.moveTo(ZUO_PIN_SHU_X, ZUO_PIN_SHU_Y,duration=0.5)\n",
    "            #     作品数OCR\n",
    "            img_after_cut_path = SCREENSHOT_SAVE_DIR + \"/\" + \"zuo_pin_shu\" + \".png\"\n",
    "            pyautogui.screenshot(img_after_cut_path, region=(ZUO_PIN_SHU_X, ZUO_PIN_SHU_Y, ZUO_PIN_SHU_WIDTH, ZUO_PIN_SHU_HEIGHT))\n",
    "            ocr_result = test_baidu_ocr.get_ocr_result(img_after_cut_path)\n",
    "            if ocr_result is None or \"words_result\" not in ocr_result:\n",
    "                print(\"!!!!!此次OCR结果为空, 等一会儿再试看看1\")\n",
    "                time.sleep(3)\n",
    "                continue\n",
    "            print(\"ocr_result:{}\".format(ocr_result))\n",
    "            break\n",
    "            \n",
    "        b_page_ok = False\n",
    "        for word_result in ocr_result[\"words_result\"]:\n",
    "            words = word_result[\"words\"]\n",
    "            assert \"作品\" in words\n",
    "            int_number = int(words.replace(\"作品\", \"\"))\n",
    "            b_page_ok = True\n",
    "            break\n",
    "        print(\"作品数：{}\".format(int_number))\n",
    "        assert b_page_ok == True\n",
    "        # chenyj test\n",
    "        if \"zuo_pin_shu\" in DEVICE_LIST[i_current_device_index]:\n",
    "            if int_number > DEVICE_LIST[i_current_device_index][\"zuo_pin_shu\"]:\n",
    "        #if True:\n",
    "        #    if True:\n",
    "                # 此时发送微信通知自己\n",
    "                str_in = \"主人，【{}】主页发现了新作品({}->{})\".format(DEVICE_LIST[i_current_device_index][\"name\"], DEVICE_LIST[i_current_device_index][\"zuo_pin_shu\"], int_number)\n",
    "                wei_xin_notify(str_in)\n",
    "                # chenyj test\n",
    "                \"\"\"\n",
    "                url_new_video = get_video_url_of_dian_zan_least()\n",
    "                if len(url_new_video) != 0:\n",
    "                    new_video_url_list.add(url_new_video)\n",
    "                \"\"\"\n",
    "                \n",
    "        DEVICE_LIST[i_current_device_index][\"zuo_pin_shu\"] = int_number\n",
    "        \n",
    "        # 调整计数\n",
    "        i_current_device_index += 1\n",
    "        if i_current_device_index >= len(DEVICE_LIST):\n",
    "            i_current_device_index = 0\n",
    "            # 将作品数据保存\n",
    "            save_zuo_pin_shu_to_file(DEVICE_LIST, home_page_group[\"zuo_pin_shu_save_path\"])\n",
    "            time.sleep(INTER_WAIT_SECONDS)\n",
    "            \n",
    "            \n",
    "        continue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Win32Window left=\"-8\", top=\"-8\", width=\"1382\", height=\"744\", title=\"童心手工屋的主页 - 抖音 - Google Chrome\">\n",
      "LEI_DIAN_FW_LEFT:-8\n",
      "LEI_DIAN_FW_TOP:-8\n",
      "LEI_DIAN_FW_BOTTOM:736\n",
      "LEI_DIAN_FW_WIDTH:1382\n",
      "LEI_DIAN_FW_HEIGHT:744\n",
      "<Win32Window left=\"-8\", top=\"-8\", width=\"1382\", height=\"744\", title=\"生活妙招库的主页 - 抖音 - Google Chrome\">\n",
      "LEI_DIAN_FW_LEFT:-8\n",
      "LEI_DIAN_FW_TOP:-8\n",
      "LEI_DIAN_FW_BOTTOM:736\n",
      "LEI_DIAN_FW_WIDTH:1382\n",
      "LEI_DIAN_FW_HEIGHT:744\n",
      "ocr_result:{'log_id': 1602276009703471457, 'words_result': [{'words': '作品227', 'location': {'top': 9, 'left': 7, 'width': 73, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：227\n",
      "已经完成了2个主页,平均速度0.11378484303129607个/秒，8.788516759872437秒/个\n",
      "ocr_result:{'log_id': 1602276068043689758, 'words_result': [{'words': '作品68', 'location': {'top': 10, 'left': 7, 'width': 65, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：68\n",
      "将作品数保存到文件zuo_pin_shu_from_dou_yin_1.txt中\n",
      "ocr_result:{'log_id': 1602276268361013604, 'words_result': [{'words': '作品31', 'location': {'top': 9, 'left': 6, 'width': 63, 'height': 19}}], 'words_result_num': 1}\n",
      "作品数：31\n",
      "已经完成了4个主页,平均速度0.050506582599491597个/秒，19.799399375915527秒/个\n",
      "ocr_result:{'log_id': 1602276326771052787, 'words_result': [{'words': '作品572', 'location': {'top': 10, 'left': 7, 'width': 75, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：572\n",
      "ocr_result:{'log_id': 1602276388824942363, 'words_result': [{'words': '作品627', 'location': {'top': 10, 'left': 7, 'width': 74, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：627\n",
      "将作品数保存到文件zuo_pin_shu_from_dou_yin_2.txt中\n",
      "已经完成了6个主页,平均速度0.04345510791851763个/秒，23.01225443681081秒/个\n",
      "ocr_result:{'log_id': 1602276590888551135, 'words_result': [{'words': '作品227', 'location': {'top': 9, 'left': 7, 'width': 73, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：227\n",
      "ocr_result:{'log_id': 1602276646243602366, 'words_result': [{'words': '作品68', 'location': {'top': 10, 'left': 7, 'width': 65, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：68\n",
      "将作品数保存到文件zuo_pin_shu_from_dou_yin_1.txt中\n",
      "已经完成了8个主页,平均速度0.04013769533162746个/秒，24.914235651493073秒/个\n",
      "ocr_result:{'log_id': 1602276846526411013, 'words_result': [{'words': '作品31', 'location': {'top': 9, 'left': 6, 'width': 63, 'height': 19}}], 'words_result_num': 1}\n",
      "作品数：31\n",
      "ocr_result:{'log_id': 1602276904350151866, 'words_result': [{'words': '作品572', 'location': {'top': 10, 'left': 7, 'width': 75, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：572\n",
      "已经完成了10个主页,平均速度0.0433412330766108个/秒，23.072716879844666秒/个\n",
      "ocr_result:{'log_id': 1602276960761319440, 'words_result': [{'words': '作品627', 'location': {'top': 10, 'left': 7, 'width': 74, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：627\n",
      "将作品数保存到文件zuo_pin_shu_from_dou_yin_2.txt中\n",
      "ocr_result:{'log_id': 1602277160642225314, 'words_result': [{'words': '作品227', 'location': {'top': 9, 'left': 7, 'width': 73, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：227\n",
      "已经完成了12个主页,平均速度0.0411206465667058个/秒，24.31868376334508秒/个\n",
      "ocr_result:{'log_id': 1602277217510144257, 'words_result': [{'words': '作品68', 'location': {'top': 10, 'left': 7, 'width': 65, 'height': 18}}], 'words_result_num': 1}\n",
      "作品数：68\n",
      "将作品数保存到文件zuo_pin_shu_from_dou_yin_1.txt中\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-71-e56df365d875>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mloop_look_zuo_pin_shu\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32m<ipython-input-70-baa8a1ff1aa3>\u001b[0m in \u001b[0;36mloop_look_zuo_pin_shu\u001b[1;34m()\u001b[0m\n\u001b[0;32m    100\u001b[0m             \u001b[1;31m# 将作品数据保存\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    101\u001b[0m             \u001b[0msave_zuo_pin_shu_to_file\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mDEVICE_LIST\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mhome_page_group\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"zuo_pin_shu_save_path\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 102\u001b[1;33m             \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mINTER_WAIT_SECONDS\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    103\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    104\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "loop_look_zuo_pin_shu()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
